<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	View list
</asp:Content>
<asp:Content ContentPlaceHolderID="HeadContent" runat="server">

	<script type="text/javascript">
	function confirmClear()
	{
		if( confirm( "Are you sure you want to clear this list?" ) == 1)
		{
			location = '<%= Mailer.Utilities.Configuration.RelativeRootURL %>list/Clear/<%= ViewData[ "ID" ] %>';
		}
	}
	</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<div class="pagetitle">
		<h1>
			List: <em>
				<%= ViewData[ "Name" ] %></em>
		</h1>
	</div>
	<div class="pagecontent">
		<p>
			<%= Html.ActionLink("Back to application", "View", "Application", new { ID = ViewData["ApplicationID"] }, null ) %>
			|
			<%= Html.ActionLink("Edit list properties", "Edit", "List", new { ID = ViewData["ID"] }, null ) %>
			| <a href="javascript:confirmClear();">Clear list</a>
		</p>
		<p>
			Short name:
			<%= ViewData[ "ShortName" ] %>
		</p>
		<h2>
			Recipients</h2>
		<% using (Html.BeginForm("Import", "List", FormMethod.Post, new { enctype = "multipart/form-data" }))
	 { %>
		<input type="hidden" name="list" value="<%= ViewData["ID"] %>" />
		<p>
			Import from file:
			<input type="file" name="file1" />
			format:
			<select name="format">
				<option value="csv">Comma-separated (CSV)</option>
				<option value="tsv">Tab-separated (TSV)</option>
				<option value="enter">Line-separated</option>
			</select>
			<%= Html.CheckBox( "force", false ) %>
			Force
			<input type="submit" value="Upload file" />
		</p>
		<%}%>
		<% using (Html.BeginForm("Export", "List", FormMethod.Get))
	 { %>
		<input type="hidden" name="list" value="<%= ViewData["ID"] %>" />
		<p>
			Export to a file with format
			<select name="format">
				<option value="csv">Comma-separated (CSV)</option>
				<option value="tsv">Tab-separated (TSV)</option>
				<option value="enter">Line-separated</option>
			</select>
			<input type="submit" value="Download file" />
		</p>
		<%}%>
		<% using (Html.BeginForm("View", "List", FormMethod.Get))
	 { %>
		<p>
			Search:
			<%= Html.TextBox( "q" ) %>
			<input type="submit" value="Update" />
		</p>
		<table style="width: 100%;">
			<tr>
				<th>
					E-Mail
				</th>
				<th>
					Name
				</th>
			</tr>
			<% foreach (var l in (ViewData["Recipients"] as IList<Mailer.Model.Types.Recipient>)
	   )
	  { %>
			<tr>
				<td>
					<%= Html.ActionLink(l.Email, "View", "Recipient", new { ID = l.ID }, null)%>
				</td>
				<td>
					<%= Html.ActionLink(l.GetPropertyValue("displayname","")+" ", "View", "Recipient", new { ID = l.ID }, null)%>
				</td>
			</tr>
			<% } %>
		</table>
		<% } %>
	</div>
</asp:Content>
